<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="${pageContext.request.contextPath }/h-ui/css/H-ui.min.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/h-ui/css/H-ui.admin.css"
	rel="stylesheet" type="text/css" />
<link
	href="${pageContext.request.contextPath }/h-ui/lib/Hui-iconfont/1.0.6/iconfont.css"
	rel="stylesheet" type="text/css" />
<title>面料属性管理</title>
</head>
<body>
	<nav class="breadcrumb"> <a
		class="btn btn-success radius r mr-20"
		style="line-height: 1.6em; margin-top: 3px"
		href="javascript:location.replace(location.href);" title="刷新"><i
		class="Hui-iconfont">&#xe68f;</i></a> </nav>
	<div class="pd-20">
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="l"> <a href="javascript:;"
				onclick="member_del('../patternfilter/Delete')"
				class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i>
					删除</a> <a href="javascript:;"
				onclick="member_add('添加','../patternfilter/Add','','510')"
				class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>
					添加</a> <a href="javascript:;"
				onclick="member_edit('修改','../patternfilter/Edit','','510')"
				class="btn btn-primary radius"><i class="Hui-iconfont">&#xe6df;</i>
					修改</a>
			</span>
		</div>
		<div class="mt-20">
			<table id="PatternFilter"
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="25"><input type="checkbox" name="" value=""></th>
						<th data-field="PT_ID">ID</th>
						<th data-field="PT_NAME">中文名称</th>
						<th data-field="PT_NAME_EN">英文名称</th>
						<th data-field="parentName">上级</th>
						<th data-field="PT_CREATE_TIME" data-formatter="dateFormatter">创建时间</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/lib/layer/2.1/layer.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/moment.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/js/H-ui.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/js/H-ui.admin.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/lib/Validform/5.3.2/Validform.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/tableAddData.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/jqthumb/jqthumb.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/h-ui/tableBtnGroup.js"></script>
	<script type="text/javascript">
		//编辑
		function member_edit(title, url, w, h) {
			var checkboxes = $('table tbody tr').find('input[type="checkbox"]');
			var tr_num = null;
			var checkboxVal = '';
			checkboxes.each(function() {
				if ($(this).prop('checked') == true) {
					tr_num++;
					checkboxVal = $(this).val();
				}
			});
			if (tr_num == null) {
				layer.msg('请选择要修改的数据！', {
					icon : 0,
					time : 1000
				});
			} else if (tr_num == 1) {
				for (var i = 0; i < $('table tbody tr').length; i++) {
					if ($('table tbody tr').eq(i).find('input[type=checkbox]')
							.prop('checked') == true) {
						if ($('table tbody tr').eq(i).children(4)[4].innerText == "颜色") {
							layer.msg("颜色不能编辑！", {
								icon : 0,
								time : 1000
							});
						} else if ($('table tbody tr').eq(i).children(4)[4].innerText == "") {
							layer.msg("父级不能编辑！", {
								icon : 0,
								time : 1000
							});
						} else {
							url += '?id=' + checkboxVal;
							layer_show(title, url, w, h);
						}
					}//此行是否被选中
				}//遍历所有列
			} else {
				layer.msg('请选择一条数据！', {
					icon : 0,
					time : 1000
				}, function() {
					return null;
				});
			}
		}
		//删除
		function member_del(dataUrl) {
			var checkboxes = $('table tbody tr').find('input[type="checkbox"]');
			var tr_num = null;
			var checkboxVal = [];
			checkboxes.each(function() {
				if ($(this).prop('checked') == true) {
					tr_num++;
					checkboxVal.push(parseInt($(this).val()));
				}
			});
			if (tr_num == null) {
				layer.msg('请选择要删除的数据！', {
					icon : 0,
					time : 1000
				});
			} else {
				var a = false;
				for (var i = 0; i < $('table tbody tr').length; i++) {
					if ($('table tbody tr').eq(i).find('input[type=checkbox]')
							.prop('checked') == true) {
						if ($('table tbody tr').eq(i).children(4)[4].innerText == "颜色") {
							a = true;
							i=100;
							layer.msg("颜色不能删除！", {
								icon : 0,
								time : 1000
							});
						} else if ($('table tbody tr').eq(i).children(4)[4].innerText == "") {
							a = true;
							i=100;
							layer.msg("父级不能删除！", {
								icon : 0,
								time : 1000
							});
						} else {
							a = false;							
						}
					}//此行是否被选中
				}//遍历所有列
				if (a != true) {
					layer.confirm('您一共选择了' + tr_num + '条数据，确认要删除吗？', function(
							index) {
						$.ajax({
							async : false,
							url : dataUrl + '?id=' + checkboxVal,
							type : 'post',
							success : function(result) {
								var status = result.msg.status;
								var desc = result.msg.desc;
								if (status == 0) { //删除成功！
									layer.msg(desc, {
										icon : 1,
										time : 1000
									}, function() {
										location.replace(location.href);
									});
								} else if (status == 1) { //删除失败！
									layer.msg(desc, {
										icon : 0,
										time : 1000
									});
								}
							}
						});
					});
				}
			}
		}
	</script>
</body>
</html>